<template>
  <div>
    <!-- 实用新型+发明 -->
    <!-- :width="860" -->
    <Modal
      v-model="cMox"
      :footer-hide="true"
      :mask-closable="false"
      :width="920"
      class-name="vertical-center-modal"
      @on-visible-change="vPchange"
    >
      <div
        :style="'max-height:'+($app.winHeight-100)+'px;overflow-y: auto; margin:0 -16px; padding:0 16px;'"
      >
        <div class="marginB10 overflowH marginT10">
          <div class="pullLeft marginR20" style="border-right:1px solid #eee; min-width:300px;">
            <div class="marginB10">请上传word 或 PDF格式文件</div>

            <template v-if="goods_type==101">
              <!-- 外观简要说明 -->
              <div class="pullLeft marginR20 textCenter relative">
                <Icon
                  v-show="upIsOk('appe_brief_desc_path')"
                  type="md-close-circle"
                  class="cCCC absolute pointer"
                  style="z-index:15;right:-10px;top:-10px;"
                  size="20"
                  @click="qingKk('appe_brief_desc_path')"
                />
                <div class="JC_img tran3 pointer textCenter cBlue relative">
                  <input
                    type="file"
                    ref="fA"
                    accept=".pdf, .docx, .doc"
                    class="InputFileBox"
                    @change="each_one_up($event,'appe_brief_desc_path')"
                  />
                  <Icon
                    type="ios-add-circle-outline"
                    style="padding-top:9px;"
                    size="30"
                    v-show="!upIsOk('appe_brief_desc_path')"
                  />
                  <div class="relative" v-show="upIsOk('appe_brief_desc_path')">
                    <i class="iconfont f_24 hoverTou" :class="upIsIcon('appe_brief_desc_path')"></i>
                    <span class="hoverTips">重新上传</span>
                  </div>
                </div>
                <div
                  class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                  :class="upIsLink('appe_brief_desc_path')"
                  @click="upIsOkShow('appe_brief_desc_path')"
                >
                  <div>外观简要说明</div>
                </div>
                <div class>
                  <Button
                    type="primary"
                    ghost
                    size="small"
                    @click="$app.openWindow('static/word/外观设计简要说明.doc')"
                  >下载示例</Button>
                </div>
              </div>

            </template>
            <template v-else>
              <!-- 说明书 -->
              <div class="pullLeft marginR20 textCenter relative">
                <Icon
                  v-show="upIsOk('instruction')"
                  type="md-close-circle"
                  class="cCCC absolute pointer"
                  style="z-index:15;right:-10px;top:-10px;"
                  size="20"
                  @click="qingKk('instruction')"
                />
                <div class="JC_img tran3 pointer textCenter cBlue relative">
                  <input
                    type="file"
                    ref="fA"
                    accept=".pdf, .docx, .doc"
                    class="InputFileBox"
                    @change="each_one_up($event,'instruction')"
                  />
                  <Icon
                    type="ios-add-circle-outline"
                    style="padding-top:9px;"
                    size="30"
                    v-show="!upIsOk('instruction')"
                  />
                  <div class="relative" v-show="upIsOk('instruction')">
                    <i class="iconfont f_24 hoverTou" :class="upIsIcon('instruction')"></i>
                    <span class="hoverTips">重新上传</span>
                  </div>
                </div>
                <div
                  class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                  :class="upIsLink('instruction')"
                  @click="upIsOkShow('instruction')"
                >
                  <div>说明书</div>
                </div>
                <div class>
                  <Button
                    type="primary"
                    ghost
                    size="small"
                    @click="$app.openWindow('static/word/说明书.doc')"
                  >下载示例</Button>
                </div>
              </div>

              <!-- 说明书摘要 -->
              <div class="pullLeft marginR20 textCenter relative">
                <Icon
                  v-show="upIsOk('instruction_abstract')"
                  type="md-close-circle"
                  class="cCCC absolute pointer"
                  style="z-index:15;right:-10px;top:-10px;"
                  size="20"
                  @click="qingKk('instruction_abstract')"
                />
                <div class="JC_img tran3 pointer cBlue relative">
                  <input
                    type="file"
                    ref="fB"
                    accept=".pdf, .docx, .doc"
                    class="InputFileBox"
                    @change="each_one_up($event,'instruction_abstract')"
                  />
                  <Icon
                    type="ios-add-circle-outline"
                    style="padding-top:9px;"
                    size="30"
                    v-show="!upIsOk('instruction_abstract')"
                  />
                  <div class="relative" v-show="upIsOk('instruction_abstract')">
                    <i class="iconfont f_24 hoverTou" :class="upIsIcon('instruction_abstract')"></i>
                    <span class="hoverTips">重新上传</span>
                  </div>
                </div>
                <div
                  class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                  :class="upIsLink('instruction_abstract')"
                  @click="upIsOkShow('instruction_abstract')"
                >
                  <div>说明书摘要</div>
                </div>
                <div class>
                  <Button
                    type="primary"
                    ghost
                    size="small"
                    @click="$app.openWindow('static/word/说明书摘要.doc')"
                  >下载示例</Button>
                </div>
              </div>

              <!-- 权利要求书 -->
              <div class="pullLeft marginR20 textCenter relative">
                <Icon
                  v-show="upIsOk('claims')"
                  type="md-close-circle"
                  class="cCCC absolute pointer"
                  style="z-index:15;right:-10px;top:-10px;"
                  size="20"
                  @click="qingKk('claims')"
                />
                <div class="JC_img tran3 pointer cBlue relative">
                  <input
                    type="file"
                    ref="fC"
                    accept=".pdf, .docx, .doc"
                    class="InputFileBox"
                    @change="each_one_up($event,'claims')"
                  />
                  <Icon
                    type="ios-add-circle-outline"
                    style="padding-top:9px;"
                    size="30"
                    v-show="!upIsOk('claims')"
                  />
                  <div class="relative" v-show="upIsOk('claims')">
                    <i class="iconfont f_24 hoverTou" :class="upIsIcon('claims')"></i>
                    <span class="hoverTips">重新上传</span>
                  </div>
                </div>
                <div
                  class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                  :class="upIsLink('claims')"
                  @click="upIsOkShow('claims')"
                >
                  <div>权利要求书</div>
                </div>
                <div class>
                  <Button
                    type="primary"
                    ghost
                    size="small"
                    @click="$app.openWindow('static/word/权利要求书.doc')"
                  >下载示例</Button>
                </div>
              </div>

              <!-- 说明书附图 -->
              <div class="pullLeft marginR20 textCenter relative">
                <Icon
                  v-show="upIsOk('instruction_image')"
                  type="md-close-circle"
                  class="cCCC absolute pointer"
                  style="z-index:15;right:-10px;top:-10px;"
                  size="20"
                  @click="qingKk('instruction_image')"
                />
                <div class="JC_img tran3 pointer cBlue relative">
                  <input
                    type="file"
                    ref="fD"
                    accept=".pdf, .docx, .doc"
                    class="InputFileBox"
                    @change="each_one_up($event,'instruction_image')"
                  />
                  <Icon
                    type="ios-add-circle-outline"
                    style="padding-top:9px;"
                    size="30"
                    v-show="!upIsOk('instruction_image')"
                  />
                  <div class="relative" v-show="upIsOk('instruction_image')">
                    <i class="iconfont f_24 hoverTou" :class="upIsIcon('instruction_image')"></i>
                    <span class="hoverTips">重新上传</span>
                  </div>
                </div>
                <div
                  class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                  :class="upIsLink('instruction_image')"
                  @click="upIsOkShow('instruction_image')"
                >
                  <div>说明书附图</div>
                </div>
                <div class>
                  <Button
                    type="primary"
                    ghost
                    size="small"
                    @click="$app.openWindow('static/word/说明书附图.docx')"
                  >下载示例</Button>
                </div>
              </div>

              <!-- 摘要附图 -->
              <div class="pullLeft marginR20 textCenter relative">
                <Icon
                  v-show="upIsOk('abstract_image')"
                  type="md-close-circle"
                  class="cCCC absolute pointer"
                  style="z-index:15;right:-10px;top:-10px;"
                  size="20"
                  @click="qingKk('abstract_image')"
                />
                <div class="JC_img tran3 pointer cBlue relative">
                  <input
                    type="file"
                    ref="fP"
                    accept=".pdf, .docx, .doc"
                    class="InputFileBox"
                    @change="each_one_up($event,'abstract_image')"
                  />
                  <Icon
                    type="ios-add-circle-outline"
                    style="padding-top:9px;"
                    size="30"
                    v-show="!upIsOk('abstract_image')"
                  />
                  <div class="relative" v-show="upIsOk('abstract_image')">
                    <i class="iconfont f_24 hoverTou" :class="upIsIcon('abstract_image')"></i>
                    <span class="hoverTips">重新上传</span>
                  </div>
                </div>
                <div
                  class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                  :class="upIsLink('abstract_image')"
                  @click="upIsOkShow('abstract_image')"
                >
                  <div>摘要附图</div>
                </div>
              </div>

            </template>

            
          </div>
          <div class="pullLeft marginR20" style="border-right:1px solid #eee; ">
            <div class="marginB10">格式 .doc</div>
            <!-- 专利请求书 -->
            <div class="pullLeft marginR20 textCenter relative">
              <Icon
                v-show="upIsOk('apply_path')"
                type="md-close-circle"
                class="cCCC absolute pointer"
                style="z-index:15;right:-10px;top:-10px;"
                size="20"
                @click="qingKk('apply_path')"
              />

              <div class="JC_img tran3 pointer textCenter cBlue relative">
                <input
                  type="file"
                  ref="fR"
                  accept=".doc"
                  class="InputFileBox"
                  @change="each_one_up($event,'apply_path')"
                />
                <div v-show="!upIsOk('apply_path')">
                  <Icon type="ios-add-circle-outline" style="padding-top:11px;" size="26" />
                  <span class="f_12 relative" style="top:-3px;">
                    {{goods_type_name()}}
                  </span>
                </div>
                <div class="relative" v-show="upIsOk('apply_path')">
                  <i class="iconfont f_24 hoverTou" :class="upIsIcon('apply_path')"></i>
                  <span class="hoverTips">重新上传</span>
                </div>
              </div>
              <div
                class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                :class="upIsLink('apply_path')"
                @click="upIsOkShow('apply_path')"
              >
                <div class="f_12">专利请求书</div>
              </div>
              <div class>
                <Button type="primary" ghost size="small" @click="wxT_dowH">下载示例</Button>
              </div>
            </div>
          </div>
          <div class="pullLeft">
            <div class="marginB10">请上传 图片</div>
            <!-- 代理委托书 -->
            <div class="pullLeft textCenter relative">
              <Icon
                v-show="upIsOk('bz_weituo')"
                type="md-close-circle"
                class="cCCC absolute pointer"
                style="z-index:15;right:-10px;top:-10px;"
                size="20"
                @click="qingKk('bz_weituo')"
              />
              <div class="JC_img tran3 pointer cBlue relative">
                <input
                  type="file"
                  ref="fF"
                  accept="image/*"
                  class="InputFileBox"
                  @change="btnBWT($event)"
                />
                <div v-show="!upIsOk('bz_weituo')">
                  <Icon type="ios-add-circle-outline" style="padding-top:9px;" size="30" />
                </div>
                <div class="relative" v-show="upIsOk('bz_weituo')">
                  <i class="iconfont f_24 hoverTou" :class="upIsIcon('bz_weituo')"></i>
                  <span class="hoverTips">重新上传</span>
                </div>
              </div>
              <div
                class="JC_img tran3 borderNone heightAuto bgTran f_12 lineH1 marginT10 marginB10"
                :class="upIsLink('bz_weituo')"
                @click="upIsOkShow('bz_weituo')"
              >
                <div>代理委托书</div>
              </div>
              <div class>
                <Button
                  type="primary"
                  ghost
                  size="small"
                  @click="$app.openWindow('static/word/代理委托书.docx')"
                >下载示例</Button>
              </div>
            </div>
          </div>
        </div>

        <template v-if="bz_oz_type==1">
          <!-- CPC自动提交 补正 -->
          <BzOaAuto ref="BzOaAuto" />
        </template>
        <template v-else>
          <!-- CPC自动提交 OA -->
          <OAone ref="OAone" />
        </template>
        <div class="marginT10">
          <!-- 外观专利 -->
          <template v-if="goods_type==101">
            <div>
              <span class="f_14">
                外观图片：
                <Button type="primary" class="pointer marginR10" size="small" shape="circle" @click="$store.commit('upData_WGZL_size')" ghost>jpg尺寸</Button>
              </span>
              
              <span class=" relative pointer marginR10">
                <input
                  type="file"
                  ref="fK"
                  accept="image/*"
                  multiple
                  class="InputFileBox pointer"
                  @change="appe_imgF($event)"
                />
                <Button type="primary" class="pointer" size="small" shape="circle">
                  <Icon type="md-add" />上传
                </Button>
              </span>
              <span class="f_bold">{{appe_img_listF.length}}</span> 
              <!-- / {{wgtp_length}} -->
              <div class="wrtR">
                <template v-for="(val,i) in appe_img_listF">
                   <div class="cBlue f_14 marginR10  inlineBlock relative marginT10">
                    <div class="textLine" style="width:80px;">
                      <img
                        :src="$app.getVal_fileUrl(val)"
                        class="contain bgWhite "
                        @click="$app.openWindow($app.getVal_fileUrl(val))"
                        style="border:1px solid #eee;"
                        width="80" height="80"
                      />
                      <div class="txtOneLine textCenter f_12 c999">{{$app.urlToName(val)}}</div>
                    </div>
                    <Icon
                      type="md-close-circle"
                      class="cCCC absolute pointer"
                      style="top:-6px;right:-6px;"
                      @click="appe_img_listF=$app.arrayDelOne(appe_img_listF,i)"
                    />
                  </div>
                </template>
              </div>

            </div>
          </template>
          <template v-else>
            <!-- 外观专利，没有对照页 -->
            <div>
              <span class="f_14 inlineBlock" style="width:160px;">对照页（word、PDF）</span>
              <span
                class="relative pointer marginR10"
                style="width:60px;height:24px;"
                v-show="compare_page_path.length<6"
              >
                <input
                  type="file"
                  ref="fG"
                  accept=".pdf, .docx, .doc"
                  multiple
                  class="InputFileBox pointer"
                  @change="more_compareList($event)"
                />
                <Button type="primary" class="pointer" size="small" shape="circle">
                  <Icon type="md-add" />上传
                </Button>
              </span>
              <span class="f_bold">{{compare_page_path.length}}</span> / 6
              <template v-for="(val,i) in compare_page_path">
                <span class="cBlue f_14 inlineBlock marginL20">
                  <span class="textLine" @click="$app.openWindow($app.getVal_fileUrl(val))">
                    <i class="iconfont f_20 inlineBlock" :class="$app.fileIcon(val)"></i>
                    对照页{{i+1}}
                  </span>
                  <Icon
                    type="md-close-circle"
                    class="cCCC relative pointer"
                    style="top:-10px;"
                    @click="compare_page_path=$app.arrayDelOne(compare_page_path,i)"
                  />
                </span>
              </template>
            </div>
          </template>
        </div>
        
        <div class="marginT10">
          <div>
            <span class="f_14 inlineBlock" style="width:160px;">其他文件（word、PDF）</span>
            <span
              class="relative pointer marginR10"
              style="width:60px;height:24px;"
              v-show="other_paths.length<3"
            >
              <input
                type="file"
                ref="fS"
                accept=".pdf, .docx, .doc"
                multiple
                class="InputFileBox pointer"
                @change="other_paths_up($event)"
              />
              <Button type="primary" class="pointer" size="small" shape="circle">
                <Icon type="md-add" />上传
              </Button>
            </span>
            <span class="f_bold">{{other_paths.length}}</span> / 3
            <template v-for="(val,i) in other_paths">
              <span class="cBlue f_14 inlineBlock marginL20">
                <span class="textLine" @click="$app.openWindow($app.getVal_fileUrl(val))">
                  <i class="iconfont f_20 inlineBlock" :class="$app.fileIcon(val)"></i>
                  文件{{i+1}}
                </span>
                <Icon
                  type="md-close-circle"
                  class="cCCC relative pointer"
                  style="top:-10px;"
                  @click="other_paths=$app.arrayDelOne(other_paths,i)"
                />
              </span>
            </template>
          </div>
        </div>

        <div class=" marginT10" style="border-top:1px solid #eee;">
          <Row>
            <Col :span="20" >
              <template v-if="$app.tomorrow(true)==time_limit">
                <div class="f_16 relative" >
                  <i class="iconfont iconjinggao1 cRed f_20 marginR10"></i>
                  <span class="cRed">今天是截止日期的最后一天</span>
                  <div class="f_12 paddingL30 c999">系统会在一个工作日（非当天）会提交到专利局，逾期可能产生权利恢复费用，提交后请联系客服处理。</div>
                </div>
              </template>
              <template v-else-if="$app.vsTime($app.today(true),time_limit)">
                <div class="f_16 relative marginT10 c999" >
                  <i class="iconfont iconjinggao cCCC f_20 marginR10"></i>您提交的材料，系统会在一个工作日（非当天）会提交到专利局。
                </div>
              </template>
              <template v-else>
                <div class="f_16 relative" >
                  <i class="iconfont iconjinggao1 cRed f_20 marginR10"></i>
                  <span class="cRed">您的材料已逾期提交</span>
                  <div class="f_12 paddingL30 c999">系统会在一个工作日（非当天）会提交到专利局，逾期可能产生权利恢复费用，提交后请联系客服处理。</div>
                </div>
              </template>
            </Col>
            <Col :span="4" class-name="textRight">
              <Button type="primary" class="marginT10" @click="tQu">
                <Icon type="md-arrow-round-up" size="18" class="relative marginR5" />
                {{bz_oz_type==1?'提交补正':'提交OA'}}
              </Button>
            </Col>
          </Row>
        </div>
      </div>
    </Modal>
  </div>
</template>

<style lang="less" scoped>
.wrtR {
  margin-right: -16px;
  overflow-y: auto;
}
.JC_img {
  height: 50px;
  line-height: 50px;
  .hoverTips {
    color: #999;
    display: none;
  }
}
.JC_img:hover {
  .hoverTips {
    display: inline-block;
  }
  .hoverTou {
    display: none;
  }
}
</style>

<script>
import BzOaAuto from "./bzOaAuto";
import OAone from "./oAone";

export default {
  name: "box1",
  components: {
    BzOaAuto,
    OAone
  },
  data() {
    let data = {
      //弹框的类型 1补正，2oa
      bz_oz_type: "",
      bz_oz_id: "", //对应那条类表数据的ID
      time_limit:"",//期限
      //补正 或 oa 证书列表
      bz_oz: {
        //外观简要说明
        appe_brief_desc_path: {
          file_path: "",
          file_url: ""
        },


        instruction: {
          file_path: "",
          file_url: "" //说明书
        },
        instruction_abstract: {
          file_path: "",
          file_url: "" //说明书摘要
        },
        claims: {
          file_path: "",
          file_url: "" //权利要求书
        },
        instruction_image: {
          file_path: "",
          file_url: "" //说明书附图
        },
        abstract_image: {
          file_path: "",
          file_url: "" //摘要附图
        },

        apply_path: {
          file_path: "",
          file_url: "" //专利请求书
        },

        bz_weituo: {
          file_path: "",
          file_url: "", //代理委托书 补正OA都会有

          // 批过章的
          file_path1: "",
          file_url1: ""
        }
      },

      // 专利+OA 都有 对照页，可以上传多张，外观专利咩有对照页
      compare_page_path: [
        // 就这个格式，默认空数组
        // {
        //   file_path: "",
        //   file_url: ""
        // }
      ],

      // 专利+OA 都有 其他文件
      other_paths: [
        // 就这个格式，默认空数组
        // {
        //   file_path: "",
        //   file_url: ""
        // }
      ],
      appe_img_listF: [
        // 就这个格式，默认空数组
        // {
        //   file_path: "",
        //   file_url: ""
        // }
      ],
    };
    let tool = {
      cMox: false, //弹框显示
      wgtp_length:99999,//外观图片最大上传多数张？
    };
    return Object.assign(data, tool);
  },
  props: ["goods_type"],//goods_type:100实用新型、101外观设计、102发明
  mounted() {},
  methods: {
    goods_type_name(){
      let{goods_type}=this;
      let out='';
      if(goods_type==100){
        out='实用新型';
      }else if(goods_type==101){
        out='外观设计';
      }else if(goods_type==102){
        out='发明';
      }
      return out;
    },
    wxT_dowH(){
      let{goods_type}=this;
      let name='';
      if(goods_type==100){
        name='实用新型专利请求书.doc';
      }else if(goods_type==101){
        name='外观设计专利请求书.doc';
      }else if(goods_type==102){
        name='发明专利请求书.doc';
      }
      $app.openWindow('static/word/'+name);
    },
    //清空
    qingKk(whoT) {
      if (whoT == "bz_weituo") {
        this.bz_oz[whoT] = {
          file_path: "",
          file_url: "",

          // 批过章的
          file_path1: "",
          file_url1: ""
        };
      } else {
        this.bz_oz[whoT] = { file_path: "", file_url: "" };
      }
    },
    //文件框单独上传是否ok
    upIsOk(whoT) {
      let out = false;
      out = $app.getVal_fileUrl(this.bz_oz[whoT]);
      return out;
    },
    upIsOkShow(whoT) {
      this.upIsOk(whoT) && $app.openWindow(this.upIsOk(whoT));
    },
    upIsIcon(whoT) {
      return $app.judgeData(this.bz_oz) ? $app.fileIcon(this.bz_oz[whoT]) : "";
    },
    upIsLink(whoT) {
      return this.upIsOk(whoT) ? " underline textLine cBlue" : "";
    },

    // 补正必填项，循环
    biTt_do(){

      /////////////////////必填项循环/////////////////////
      let bZTem = this.$refs["BzOaAuto"];
      let buZList = bZTem.buZList;
      for (let i = 0; i < buZList.length; i++) {
        let { filename, pages, cpcInfo } = buZList[i];

        if (!$app.judgeData($app.delSpace(filename))) {
          $app.alert("请输入补正文件名称", "补正"+(i+1), () => {
            this.$nextTick(() => {
              bZTem.$refs["filename" + i][0].focus();
              buZList[i].filename = "";
            });
          });
          return false;
        }

        // if (!$app.judgeData($app.delSpace(pages))) {
        //   $app.alert("请输入页数", "补正"+(i+1), () => {
        //     this.$nextTick(() => {
        //       bZTem.$refs["pages" + i][0].focus();
        //       buZList[i].pages = "";
        //     });
        //   });
        //   return false;
        // }

        if (!$app.judgeData($app.delSpace(cpcInfo[0].position))) {
          $app.alert(
            "请输入文件中的位置",
            "补正"+(i+1),
            () => {
              this.$nextTick(() => {
                bZTem.$refs["position" + i + "-0"][0].focus();
                buZList[i].cpcInfo[0].position = "";
              });
            }
          );
          return false;
        }
        if (!$app.judgeData($app.delSpace(cpcInfo[0].before))) {
          $app.alert(
            "请输入补正前的内容",
            "补正"+(i+1),
            () => {
              this.$nextTick(() => {
                bZTem.$refs["before" + i + "-0"][0].focus();
                buZList[i].cpcInfo[0].before = "";
              });
            }
          );
          return false;
        }
        if (!$app.judgeData($app.delSpace(cpcInfo[0].after))) {
          $app.alert(
            "请输入补正后的内容",
            "补正"+(i+1),
            () => {
              this.$nextTick(() => {
                bZTem.$refs["after" + i + "-0"][0].focus();
                buZList[i].cpcInfo[0].after = "";
              });
            }
          );
          return false;
        }
      }
      /////////////////////必填项循环/////////////////////

      return true;
    },

    //OA形式答复
    biTt_do_OA(){
      //弹框的类型 1补正，2oa
      let{bz_oz_type}=this;

      let getTextJut='';

      if(bz_oz_type==1){
        getTextJut=this.$refs["BzOaAuto"].$refs["OAone"].getText();
      }else{
        getTextJut=this.$refs["OAone"].getText();
      }

      if(!$app.judgeData($app.delSpace(getTextJut))){
        $app.alert('答复内容不能为空');
        return false;
      }
      return true;
    },

    //cpcGo1 + cpcGo2 合体
    cpcGo_Ok(content_json,content_txt){
      let {
        bz_oz_type: type,
        bz_oz_id: correct_id,
        compare_page_path, //对照页
        other_paths,//其他文件
        appe_img_listF,//外观图片
        bz_oz: {
          // 外观专利
          appe_brief_desc_path:{file_path:appe_brief_desc_path},

          // 五书
          instruction: { file_path: instruction },
          instruction_abstract: { file_path: instruction_abstract },
          claims: { file_path: claims },
          instruction_image: { file_path: instruction_image },
          abstract_image: { file_path: abstract_image },
          
          //专利请求书
          apply_path: {file_path: apply_path},

          //代理委托书
          bz_weituo: { file_path: bz_weituo, file_path1: bz_weituo1 },

        }
      } = this;

      
      let appe_img_list = $app.judgeData(appe_img_listF) ? JSON.stringify($app.filePath_forEach(appe_img_listF)): "";
      let comparePagePath = $app.judgeData(compare_page_path) ? JSON.stringify($app.filePath_forEach(compare_page_path)): "";
      let otherPaths = $app.judgeData(other_paths)?JSON.stringify($app.filePath_forEach(other_paths)): "";

      
      let goObj = {
        correct_id,
        type,
        
        //补正文件
        content_json, 
        content_txt,

        //外观专利
        appe_brief_desc_path,

        // 五书
        instruction,
        instruction_abstract,
        claims,
        instruction_image,
        abstract_image,
        apply_path,

        bz_weituo,
        bz_weituo1,

        compare_page_path: comparePagePath, // 对照页
        other_paths:otherPaths,//其他文件
        appe_img_list//外观图片
      };

      console.log('看看  = ',goObj);

      $ajax.patentCo(goObj, resData => {
        this.cMox = false; //关闭弹框
        $app.toast("资料提交成功", true);
        //由于多层组件嵌套，所以只能这样，找父亲的父亲的父亲，日后再用vuex优化
        this.$parent.$parent.$parent.$parent.$parent.getData(); //更新 专利详情
      });
      
    },

    //补正提交
    cpcGo1() {
      
      // 1填填填补正 2富文本补正
      let bz_switch_type=this.$refs["BzOaAuto"].bz_switch_type;
      let content_json ='',content_txt='';
      if(bz_switch_type==1){
        if(!this.biTt_do()) return;// 补正补正必填项循环
        content_json = JSON.stringify(this.$refs["BzOaAuto"].buZList);//认证全部通过 取得cpc自动提交的上传文件
      }else{
        if(!this.biTt_do_OA()) return;// 以OA形式答复
        // content_txt=JSON.stringify(this.$refs["BzOaAuto"].$refs["OAone"].getHtml());
        content_txt=this.$refs["BzOaAuto"].$refs["OAone"].getHtml();
      }

      this.cpcGo_Ok(content_json,content_txt);
        
    },

    // OA 自动化
    cpcGo2() {
      let content_json ='',content_txt='';
      if(!this.biTt_do_OA()) return;// 以OA形式答复
      // content_txt=JSON.stringify(this.$refs["OAone"].getHtml());
      content_txt=this.$refs["OAone"].getHtml();

      this.cpcGo_Ok(content_json,content_txt);
    },
    //提交文件
    tQu() {
      if (this.bz_oz_type == 1) {
        this.cpcGo1();
      } else {
        this.cpcGo2();
      }
    },

    //下载示例
    main_fileXx() {
      let { bz_oz_type } = this;
      if (bz_oz_type == 1) {
        $app.openWindow("static/word/补正书.doc");
      } else {
        $app.openWindow("static/word/意见陈述书.docx");
      }
    },
    //弹框显示执行
    vPchange(buEr) {
      if (buEr) {
        //显示
      } else {
        //隐藏
        setTimeout(() => {
          //清空数据
          this.bz_oz_type = "";
          this.bz_oz_id = "";
          this.time_limit="";//期限
          this.bz_oz = {
            //外观简要说明
            appe_brief_desc_path: {
              file_path: "",
              file_url: ""
            },

            instruction: {
              file_path: "",
              file_url: "" //说明书
            },
            instruction_abstract: {
              file_path: "",
              file_url: "" //说明书摘要
            },
            claims: {
              file_path: "",
              file_url: "" //权利要求书
            },
            instruction_image: {
              file_path: "",
              file_url: "" //说明书附图
            },
            abstract_image: {
              file_path: "",
              file_url: "" //摘要附图
            },
            apply_path: {
              file_path: "",
              file_url: "" //专利请求书
            },

            bz_weituo: {
              file_path: "",
              file_url: "", //代理委托书 补正OA都会有

              // 批过章的
              file_path1: "",
              file_url1: ""
            }
          };
          this.compare_page_path = [];
          this.other_paths=[];
          this.appe_img_listF=[];
          
        }, 200);
      }

      // 初始化数据
      setTimeout(() => {
        //初始化子组件数据
        if ($app.judgeData(this.$refs["BzOaAuto"])) {
          this.$refs["BzOaAuto"].buZList = [
            {
              filename: "",
              pages: "",
              cpcInfo: [{ position: "", before: "", after: "" }]
            }
          ];
        }
        //初始化子组件数据
        if ($app.judgeData(this.$refs["OAone"])) {
          this.$refs["OAone"].clearHtml();
        }
      }, 300);
    },
    //单独每个文件上传
    each_one_up(e, whoT) {
      let file = e.target.files[0]; //选中的文件

      //格式判断
      if(whoT=='apply_path'){//专利请求书=>只要 doc 格式
        $app.suffix.docJust(e, file, false, () => {
          this.peiHe_Do(25,file,whoT);//25补正+OA=》专利请求书=》纯.doc文件 
        });
      }else{
        let type = (this.bz_oz_type == 1 ? 10 : 11);//文件上传位置
        $app.suffix.wp(e, file, false, () => {
          this.peiHe_Do(type,file,whoT);
        });
      }
    },
    //配合上者使用
    peiHe_Do(type,file,whoT){
      
      //type:
      //1营业执照,2专利文件,3身份证,4外观设计图片,5外观说明文件,6软著文件,7美术著作文件,8商标文件,9商标导入文件-xls,
      //10专利补正文件,11专利oa文件,12专利打包文件(zip/rar),13专利委托书,14企业头像,15商标委托书,xxxx
      $ajax.upOther(file,type,resData => {
        this.bz_oz[whoT] = resData;

        this.value_kong();
      },() => {
        this.value_kong();
      });
    },
    //补正 外观图片列表
    appe_imgF(e) {
      this.upData_to_Jt(e,this.wgtp_length,'appe_img_listF',()=>{
        // 外观专利图片上传 专用=>多种判断合一
        $app.WGZL_EachImg_judge(e,(resData, file_name) => {
          this.appe_img_listF.push(resData);
          this.$refs["fK"].value = "";
        });
      });
    },
    //配合上者使用-清空ALL
    value_kong(){
      // 五书上传框 清空
      $app.judgeData(this.$refs["fA"]) && (this.$refs["fA"].value = "");
      $app.judgeData(this.$refs["fB"]) && (this.$refs["fB"].value = "");
      $app.judgeData(this.$refs["fC"]) && (this.$refs["fC"].value = "");
      $app.judgeData(this.$refs["fD"]) && (this.$refs["fD"].value = "");
      $app.judgeData(this.$refs["fP"]) && (this.$refs["fP"].value = "");
      $app.judgeData(this.$refs["fR"]) && (this.$refs["fR"].value = "");//专利请求书
      $app.judgeData(this.$refs["fF"]) && (this.$refs["fF"].value = "");//清空input file的值
      $app.judgeData(this.$refs["fG"]) && (this.$refs["fG"].value = "");
      $app.judgeData(this.$refs["fK"]) && (this.$refs["fK"].value = "");
      $app.judgeData(this.$refs["fS"]) && (this.$refs["fS"].value = "");
    },
    // 代理委托书 上传图片
    btnBWT(e) {
      //只有 bz_oz_type ==1 才有这个框，补正
      let file = e.target.files[0]; //选中的文件

      //格式判断
      $app.suffix.jpgPng(e, file, false, () => {
        //base64图片上传:
        //upload_type:1营业执照,2专利文件,3身份证,4外观设计图片,xxxxx
        $app.selectFileImage(null,null,file,13,resData => {
          this.bz_oz["bz_weituo"] = resData;
          this.value_kong(); //清空input file的值
        },() => {
          this.value_kong(); //清空input file的值
        });
      });
    },
    //补正+OA 对照页
    more_compareList(e) {
      this.upData_together(e,6,'compare_page_path');
    },
    //其他文件
    other_paths_up(e) {
      this.upData_together(e,3,'other_paths');
    },
    upData_together(e,numT,whoT){
      this.upData_to_Jt(e,numT,whoT,()=>{
        $app.suffixEach(e, file => {
          //格式判断
          $app.suffix.wp(e,file,false,() => {
            $ajax.upOther(file,18,(resData, file_name) => {
              
              resData.file_name = file_name;
              this[whoT].push(resData);

              this.value_kong(); //清空input file的值
            },() => {
              this.value_kong(); //清空input file的值
            });
          },true);
        });
      });
    },
    upData_to_Jt(e,numT,whoT,callBack){
      // 最大 条数量限制
      let tiaoA = e.target.files.length;
      let tiaoB = numT - this[whoT].length;

      if (tiaoA <= numT && tiaoB >= tiaoA) {
        callBack();
      } else {
        $app.toast("最多上传"+numT+"份", false);

        //清空input file的值 两种方法都可以
        // this.$refs["fG"].value = "";
        e.target.value = "";
      }
    },
  }
};
</script>

